/************** init.html **************/
function queryGoods_goods(page) {
	sys_loading();
	var parm = $('#queryGoodsForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('goods-query');
	sys_record_parm('goods',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#goodsResultList').html(result);
		}
	});
}


function shield_goods(code, name) {
	$.Zebra_Dialog('确定是否屏蔽'+name + ' 物品吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('goods-shield');
    	   aidExecuteGoods_goods(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function unshield_goods(code, name) {
	$.Zebra_Dialog('确定要给'+name + ' 物品解除屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('goods-unshield');
    	   aidExecuteGoods_goods(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}
function aidExecuteGoods_goods(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				queryGoods_goods();
			} else {
				sys_msg('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}

function selectOrganization_goods() {
	var url = create_url('goods-aidInit');
	var parm = {'id':'oc', 'name':'on'};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'800px', height:'600px', open:true});
}

function saveGoods_goods() {
	var name = $('#name').val();
	if(name == null || name == ''){
		sys_msg('亲，还没有填名字哦！');
		return false;
	}
	var parm = $('#editGoodsForm').serialize();
	var url = create_url('goods-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功!');
				sys_load_handle('goods');
			} else if(result == 'exists') {
				sys_msg('名称重复!');
			} else {
				sys_msg('操作失败！')
			}
		}
	});
}

function selectType_goods() {
	var url = create_url('goods-type');
	var parm = {'id':'gtc', 'name':'gtn'};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'800px', height:'600px', open:true});
}